package com.promis.widget.mediapicker;

import android.content.Context;
import android.content.Intent;

import com.promis.widget.mediapicker.manager.VideoPickerListener;
import com.promis.widget.mediapicker.manager.VideoPickerManager;
import com.promis.widget.mediapicker.ui.VideoPickerActivity;

/**
 * Created by jidanbo on 2018/3/26.
 */

public class VideoPickerApi {

    public static Builder with(Context context) {
        Builder builder = new Builder(context);
        return builder;
    }

    public static class Builder {

        private Context context;

        public Builder(Context context) {
            this.context = context;
        }

        public Builder maxDuration(int duration) {
            VideoPickerManager.getInstance().setMaxDuration(duration);
            return this;
        }

        public Builder maxFileSize(int fileSize) {
            VideoPickerManager.getInstance().setMaxFileSize(fileSize);
            return this;
        }

        public Builder subscribe(VideoPickerListener listener) {
            VideoPickerManager.getInstance().setVideoPickerListener(listener);
            return this;
        }

        public void open() {
            Intent intent = new Intent(this.context, VideoPickerActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            this.context.startActivity(intent);
        }
    }
}
